#include "Stdafx.h"
#include "ContainerCreate.h"
#include "ContainerTest.h"

int32_t wmain(int32_t nArgc, const wchar_t* pArgv[]) {
    vector<wstring> Args(&pArgv[0], &pArgv[0 + nArgc]);
    shared_ptr<Interface> Intf = make_shared<Interface>(Args);
    shared_ptr<ApiTable> DynamicApis = make_shared<ApiTable>(Intf);

    if(!IsInAppContainer())
    {
        HANDLE hMutex = CreateMutexW(nullptr, true, L"MyTestAppContainer");
        EnumerateNtObjectDirectory(Intf, DynamicApis, pArgv[1]);
        RunExecutableInContainer((wchar_t *)pArgv[0]);
        system("pause");
    }else{
        HANDLE hMutex = CreateMutexW(nullptr, true, L"MyTestAppContainer2");

        if (hMutex == nullptr) {
            Intf->Log("... mutex creation from app container failed (error %d)\r\n", GetLastError());
        }
        else {
            Intf->Log("... mutex creation from app container success\r\n");
        }

        EnumerateNtObjectDirectory(Intf, DynamicApis, L"\\BaseNamedObjects");
        RunContainerTests();
    }
    getchar();

    return 0;
}